/*
 * Copyright 2006 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.gwt.user.client.ui.impl;

import com.google.gwt.user.client.Element;

/**
 * Internet Explorer 6 implementation of
 * {@link com.google.gwt.user.client.ui.impl.PopupImpl}.
 */
public class PopupImplIE6 extends PopupImpl {

  public native Element createElement() /*-{
    var outer = $doc.createElement('div');
    var frame = $doc.createElement('iframe');
    var inner = $doc.createElement('div');

    outer.appendChild(frame);
    outer.appendChild(inner);
    frame.scrolling = 'no';
    frame.style.zIndex = -1;
    frame.frameBorder = 0;

    outer.style.position = 'absolute';
    frame.style.position = 'absolute';
    inner.style.position = 'absolute';
    return outer;
  }-*/;

  public native void fixup(Element popup) /*-{
    var width = 0, height = 0;

    // Get the child's size, if any.
    var child = popup.children[1].firstChild;
    if (child) {
      width = child.offsetWidth;
      height = child.offsetHeight;
    }

    // Resize the iframe and inner div to give the child room.
    popup.children[0].style.width = popup.children[1].style.width = width;
    popup.children[0].style.height = popup.children[1].style.height = height;
  }-*/;

  public native void setHeight(Element popup, String height) /*-{
    popup.style.height =
    popup.children[0].style.height =
    popup.children[1].style.height = height;
  }-*/;

  public native void setWidth(Element popup, String width) /*-{
    popup.style.width =
    popup.children[0].style.width =
    popup.children[1].style.width = width;
  }-*/;
}
